/**
 * 
 */
package com.ap.generator.confirmpayment;

import static com.ap.datagen.core.GeneratorHelper.buildA;
import static com.ap.datagen.core.Nullable.nullable;

import com.ap.core.cxf.jaxb.managepayment.AbstractConfirmPayment1RequestGeneratorBuilder;
import com.ap.core.cxf.jaxb.managepayment.ConfirmPayment1Request;
import com.ap.core.cxf.jaxb.paymentdetails.TransactionStatusCode;
import com.ap.core.cxf.jaxb.paymentdetails.TxnStatusType;
import com.ap.generator.fi.ConsumerAcctTypeGeneratorBuilder;
import com.ap.generator.messageheader.ConfirmPaymentMsgHdrTypeGeneratorBuilder;
import com.ap.paymentdetails.PaymtDetailsTypeGeneratorBuilder;

/**
 * @author Teja.Yarlagadda
 *
 */
public class ConfirmPaymentRequestGeneratorBuilder extends
AbstractConfirmPayment1RequestGeneratorBuilder {

	/* (non-Javadoc)
	 * @see com.ap.xsd.managepaymentdata_1.AbstractConfirmPayment1RequestGeneratorBuilder#setupDefaults()
	 */
	@Override
	public void setupDefaults() {
		this.msgHdrGenerator =  nullable(buildA(ConfirmPaymentMsgHdrTypeGeneratorBuilder.msgHdrTypeGenerator()));
		this.paymtDetailsGenerator = nullable(buildA(PaymtDetailsTypeGeneratorBuilder.getPaymtDetailsTypeGeneratorBuilder()));
		this.consumerAcctGenerator = nullable(buildA(ConsumerAcctTypeGeneratorBuilder.getConsumerAcctTypeGenerator()));
	}

	public static ConfirmPaymentRequestGeneratorBuilder getConfirmPaymentRequestGenerator() {
		return new ConfirmPaymentRequestGeneratorBuilder();
	}

	
	public ConfirmPayment1Request getConfirmPaymentType(TxnStatusType txnStatusType) {
		ConfirmPayment1Request confirmPayment1Request = ConfirmPaymentRequestGeneratorBuilder.getConfirmPaymentRequestGenerator().build().generate();
		confirmPayment1Request.getPaymtDetails().getPaymentStatusInfo().setTxnStatus(txnStatusType);

		if(txnStatusType.equals(txnStatusType.DECLINED)) {
			confirmPayment1Request.getPaymtDetails().getPaymentStatusInfo().setTxnStatusCode(TransactionStatusCode.A_01);
		}

		return confirmPayment1Request;
	}
}
